package API_Jung;

import edu.uci.ics.jung.visualization.VisualizationViewer;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList;
import java.util.Iterator;
import javax.swing.JMenuItem;
import javax.swing.table.DefaultTableModel;

public class DeleteVertexMenuItemToDo<ToDoNode> extends JMenuItem implements VertexMenuListener<ToDoNode>, java.io.Serializable {

    private ToDoNode vertex;
    private VisualizationViewer visComp;
    

    /** Creates a new instance of DeleteVertexMenuItem */
    public DeleteVertexMenuItemToDo() {
        super("Delete Vertex");
        this.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                visComp.getPickedVertexState().pick(vertex, false);
                visComp.getGraphLayout().getGraph().removeVertex(vertex);
                visComp.repaint();

            }
        });
    }

    /**
     * Implements the VertexMenuListener interface.
     * @param v 
     * @param visComp 
     */
    @Override
    public void setVertexAndView(ToDoNode v, VisualizationViewer visComp) {
        this.vertex = v;
        this.visComp = visComp;
        this.setText("Delete Vertex");
    }
}
